this.name        = "Pirate_Coves"; 
this.author      = "lazygun (JS adaption by EW)"; 
this.copyright   = "lazygun"; 
this.description = "Adds pirate coves to the system."; 
this.version     = "1.2.1"; 

this.shipExitedWitchspace = function()
{
    if(!system.isInterstellarSpace && System.countShipsWithPrimaryRole("pirate") > 9 && System.countShipsWithRole("pirate-cove") == 0 && !System.sun.hasGoneNova)
    {
		var position = [0, 0, 0.10+Math.random()*0.3];
		var coordinateSystem;
		if(Math.random()< 0.1) coordinateSystem = "psu"; else coordinateSystem = "wpu";
		System.legacy_addShipsAt("pirate-cove", 1, coordinateSystem, position);
		System.legacy_addShipsAt("asteroid", 8, coordinateSystem, position);
	}
}

// System.countShipsWithPrimaryRole is only available since 1.72